import axios from 'axios'
import request from '../utils/request'
// https://website.fnji.com/mt/s/ProductCategoryModel/enum?fnjiType=1
// 请求第三方网站分类数据
export const fnjiCategoryGet = (type)=>{
  let url = `/fnji/mt/s/ProductCategoryModel/enum?fnjiType=${type}`
  return axios.get(url)
}

// 请求第三方网站医院数据
export const dayiHospitalGet = ()=>{
  let url = `/dayi/api/hospital/list2?pageNo=3&pageSize=10`
  return axios.get(url)
}

// 测试第三方网站POST接口
export const testPost = ()=>{
  let url = `/tyapi/api/app/t-talk-api/api/visitor/language/list`
  return axios.post(url,{
    encryptedCompanyId: "c49e79a32e415c086360bdae0ce3972c",
    // xxx:'xxx',
    // abc:'abc'
  })
}

//批量转存分类数据
// cateArr = [
//   {"value": "G01","name": "餐厨用品"},
//   {"value": "G02","name": "香氛洗护"}
// ]
export const categoryBatch = (cateArr,type)=>{ //cateArr是待转存的分类数据
  let arr = [
    // {
      // "method": "POST", // 1. 这一条数据执行什么操作
      // "path": "/1.1/classes/category", //2. 批量操作目标表
      // "body": { //3. 携带的数据包
      //   "value": "C09",
      //   "name": "椅/凳",
      //   "fnjiType":1
      // }
    // }
  ]
  for(let i=0;i<cateArr.length;i++){
    cateArr[i].fnjiType = type
    arr.push({
      "method": "POST", // 1. 这一条数据执行什么操作
      "path": "/1.1/classes/category", //2. 批量操作目标表
      "body": cateArr[i]
    })
  }
  return request.post('/batch',{
    "requests":arr
  })
}

//请求分类数据
export const categoryGet = (type)=>{
  return request.get(`/classes/category?where={"fnjiType":${type}}`)
}